@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

/* 暗色主题 */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;
}

/* 亮色主题 */
[data-theme="light"] {
  color-scheme: light;
  color: rgba(0, 0, 0, 0.87);
  background-color: #ffffff;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;

  &:hover {
    color: #535bf2;
  }
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 暗色主题下的 body */
[data-theme="dark"] body,
body:has([data-theme="dark"]) {
  background-color: #242424;
  color: rgba(255, 255, 255, 0.87);
}

/* 亮色主题下的 body */
[data-theme="light"] body,
body:has([data-theme="light"]) {
  background-color: #ffffff;
  color: rgba(0, 0, 0, 0.87);
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.25s, background-color 0.3s ease;

  &:hover {
    border-color: #646cff;
  }

  &:focus,
  &:focus-visible {
    outline: 4px auto -webkit-focus-ring-color;
  }
}

/* 暗色主题下的 button */
[data-theme="dark"] button {
  background-color: #1a1a1a;
  color: rgba(255, 255, 255, 0.87);
}

/* 亮色主题下的 button */
[data-theme="light"] button {
  background-color: #f9f9f9;
  color: rgba(0, 0, 0, 0.87);
}

code {
  padding: 2px 4px;
  margin: 0 4px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

/* 暗色主题下的 code */
[data-theme="dark"] code {
  background-color: #1a1a1a;
}

/* 亮色主题下的 code */
[data-theme="light"] code {
  background-color: #f9f9f9;
}

.card {
  padding: 2em;
}

#root {
  width: 100%;
  min-height: 100vh;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
}

/* 移除 prefers-color-scheme 媒体查询，改为使用 data-theme 属性 */

/* 全局 antd 样式覆盖 */
/* 移除按钮点击后的 box-shadow */
.ant-btn {
  &:focus,
  &:active,
  &:focus-visible {
    box-shadow: none !important;
    outline: none !important;
  }
}

/* 修改按钮主色样式 */
.ant-btn-primary,
[class*="ant-btn-color-primary"],
:where([class*="ant-btn-color-primary"]) {
  box-shadow: none !important;
}

/* 优化滚动条样式 */
.ant-layout-sider,
.control-panel-content,
.ant-collapse-content,
.ant-select-dropdown {
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 104, 220, 0.3) transparent;

  &::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: rgba(22, 104, 220, 0.3);
    border-radius: 3px;
    transition: background 0.2s;
  }
}